package com.hpf.blog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hpf.blog.domain.BlogCategory;
import com.hpf.blog.mapper.BlogCategoryMapper;
import com.hpf.blog.service.BlogCategoryService;
import com.ruoyi.common.exception.BusinessException;

@Service
public class BlogCategoryImpl implements BlogCategoryService{

	 @Autowired 
	private BlogCategoryMapper blogCategoryMapper;
	@Override
	public BlogCategory add(BlogCategory blogCategory) {
		if(blogCategory.getCategoryName().equals("")) {
			throw new BusinessException("分类名称不能为空！");
		}		
		return blogCategoryMapper.add(blogCategory);
	}

	@Override
	public boolean deleteById(int id){
		// TODO Auto-generated method stub
		if(id<0) {
			throw new BusinessException("非法的分类id");
		}
		int i=blogCategoryMapper.delete(id);
		return i>0?true:false;
	}

	@Override
	public BlogCategory edit(BlogCategory blogCategory) {
		// TODO Auto-generated method stub
		
		return blogCategoryMapper.edit(blogCategory);
	}

	@Override
	public BlogCategory findById(int id) {
		// TODO Auto-generated method stub

		return blogCategoryMapper.getById(id);
	}

	//@Override
	/*public List<BlogCategory> queryByParam(HashMap<String, String> map) {
		// TODO Auto-generated method stub
		return blogCategoryMapper.list(map);
	}*/

}
